package zhihui.mobile.ui.express;

import android.content.Context;
import android.widget.RelativeLayout;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.zgm.utils.DensityUtil;

import java.util.List;

import zhihui.mobile.R;
import zhihui.mobile.bean.express.ExpressUnsignedRecordBeanListV2;

/**
 * Created by Administrator on 2017/5/6 0006.
 */

public class ReceiveExpressInAdapter extends BaseQuickAdapter<ExpressUnsignedRecordBeanListV2.DataBean, BaseViewHolder> {

    private Context context;

    public ReceiveExpressInAdapter(List data, Context context) {
        super(R.layout.item_receive_express_in, data);
        this.context = context;
    }

    @Override
    protected void convert(BaseViewHolder helper, ExpressUnsignedRecordBeanListV2.DataBean item) {
        if (helper.getLayoutPosition() == 0) {
            RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) helper.getView(R.id.item_express_receive_line_view).getLayoutParams();
            lp.addRule(RelativeLayout.BELOW, R.id.item_express_receive_xiaoyuandian_iv);
            helper.getView(R.id.item_express_receive_line_view).setLayoutParams(lp);
            helper.setImageResource(R.id.item_express_receive_xiaoyuandian_iv, R.drawable.location);
            helper.setTextColor(R.id.item_express_receive_content_tv, 0xfff96733);
            helper.setTextColor(R.id.item_express_receive_time_tv, 0xfff96733);
            RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) helper.getView(R.id.item_express_receive_xiaoyuandian_iv).getLayoutParams();
            layoutParams.height = DensityUtil.dip2px(context, 20);
            layoutParams.width = DensityUtil.dip2px(context, 20);
        } else {
            RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) helper.getView(R.id.item_express_receive_xiaoyuandian_iv).getLayoutParams();
            layoutParams.height = DensityUtil.dip2px(context, 12);
            layoutParams.width = DensityUtil.dip2px(context, 12);
        }
        if (helper.getLayoutPosition() == mData.size() - 1) {
            RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) helper.getView(R.id.item_express_receive_line_view).getLayoutParams();
            lp.addRule(RelativeLayout.ABOVE, R.id.item_express_receive_xiaoyuandian_iv);
            helper.getView(R.id.item_express_receive_line_view).setLayoutParams(lp);
            helper.setTextColor(R.id.item_express_receive_content_tv, 0xff666666);
            helper.setTextColor(R.id.item_express_receive_time_tv, 0xff666666);
        }

        switch (item.getStatus_f()) {
            case 1:
                helper.setText(R.id.item_express_receive_content_tv, "待派送");
                break;
            case 2:
                helper.setText(R.id.item_express_receive_content_tv, "派送中");
                break;
            case 3:
                helper.setText(R.id.item_express_receive_content_tv, "未取");
                break;
            case 4:
                helper.setText(R.id.item_express_receive_content_tv, "已取");
                break;
        }

        helper.setText(R.id.item_express_receive_time_tv, item.getDate_f());


    }
}
